package my.peerencrypt.util;

import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * @author ZhangXiang
 * 2010-8-10
 */
public class ConfigUtil {

	protected static final Properties props = new Properties();
	private static Logger logger = Logger.getLogger(ConfigUtil.class);
	static {
		try {
			InputStream in = ConfigUtil.class.getResourceAsStream("/config.properties");
			props.load(in);
			in.close();
		} catch (Exception ex) {
			logger.error(ex);
		}
	}
	
	
	public static Properties getOneProperties(String filePath){
		try {
			InputStream in = ConfigUtil.class.getResourceAsStream(filePath);
			Properties properties = new Properties();
			properties.load(in);
			in.close();
			return properties;
		} catch (Exception ex) {
			logger.error(ex);
		}
		return null;
	}
	
	public static String getPath(String path){
		return props.getProperty(path);
	}

	public static int getInt(String key){
		return Integer.valueOf(props.getProperty(key));
	}
	public static String getString(String key){
		return props.getProperty(key);
	}
	public static float getFloat(String key){
		return Float.valueOf(props.getProperty(key));
	}
	public static Double getDouble(String key){
		return Double.valueOf(props.getProperty(key));
	}
}
